<?php
require_once(dirname(__FILE__)."/../core/safeParam.php");

if ($_GET['id'] != "") {
  $specials = $database->select("SELECT * FROM item_special where id = " . $_GET['id'] . "");
} //$_GET['id'] != ""
else {
  $specials = $database->select("SELECT * FROM item_special where rid = " . RID . " order by name");
}
for ($j = 0; $j < count($specials); $j++) {
  $specials[$j]['pizzas'] = $database->select("SELECT * FROM item_pizza where pid = " . $specials[$j]['id'] . " order by pos");
  unset($pizzas);
  $pizzas = $specials[$j]['pizzas'];
  for ($i = 0; $i < count($pizzas); $i++) {
    $specials[$j]['pizzas'][$i]['toppings']             = explode(",", trim($pizzas[$i]['toppings']));
    $specials[$j]['pizzas'][$i]['meat_toppings']        = explode(",", trim($pizzas[$i]['meat_toppings']));
    $specials[$j]['pizzas'][$i]['topoff']               = explode(",", trim($pizzas[$i]['topoff']));
    $specials[$j]['pizzas'][$i]['base']                 = explode(",", trim($pizzas[$i]['base']));
    $specials[$j]['pizzas'][$i]['sauce']                = explode(",", trim($pizzas[$i]['sauce']));
    $specials[$j]['pizzas'][$i]['pop']                  = explode(",", trim($pizzas[$i]['pop']));
    $specials[$j]['pizzas'][$i]['sides']                = unserialize($pizzas[$i]['sides']);
    $specials[$j]['pizzas'][$i]['topping_price_format'] = price_format($pizzas[$i]['topping_price']);
  } //$i = 0; $i < count($pizzas); $i++
} //$j = 0; $j < count($specials); $j++
//print_r($specials);
$smarty->assign("who_for", getOption('cb-who-for', RID));
$smarty->assign("pizzas", $specials);
$smarty->assign("topping_prices", $topping_price);
?>
